package com.enjoy.callback;

import com.alibaba.dubbo.config.annotation.Argument;
import com.alibaba.dubbo.config.annotation.Method;
import com.alibaba.dubbo.config.annotation.Service;
import com.xiangxue.jack.callback.CallbackListener;
import com.xiangxue.jack.callback.CallbackService;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Classname CallbackServiceImpl
 * @Description TODO
 * @Author Jack
 * Date 2021/6/27 20:44
 * Version 1.0
 */
@Service(methods = {@Method(name = "addListener", arguments = {@Argument(index = 1, callback = true)})})
public class CallbackServiceImpl implements CallbackService {
    @Override
    public void addListener(String s, CallbackListener callbackListener) {
        //这里就是回调客户端的方法
        callbackListener.changed(getChanged(s));
    }

    public void addListene1r(String s, CallbackListener callbackListener) {
        //这里就是回调客户端的方法
        callbackListener.changed(getChanged(s));
    }

    public void addListener2(String s, CallbackListener callbackListener) {
        //这里就是回调客户端的方法
        callbackListener.changed(getChanged(s));
    }

    public void addListener3(String s, CallbackListener callbackListener) {
        //这里就是回调客户端的方法
        callbackListener.changed(getChanged(s));
    }

    private String getChanged(String key) {
        return "Changed: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
    }
}
